package com.example.fujia.androidapp.view.fragment;

import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;

import com.example.fujia.androidapp.R;
import com.example.fujia.androidapp.activity.ArticleActivity;
import com.example.fujia.androidapp.activity.PublishActivity;
import com.example.fujia.androidapp.tools.Tools;

/**
 * Created by fujia on 2016/6/13.
 */
public class PersonFragment extends Fragment {

    private View view;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        this.view = inflater.inflate(R.layout.fg_person, container, false);

        this.setPerson();

        return view;
    }

    /**
     * 个人中心点击绑定
     * */
    private void setPerson(){
        if (!Tools.objectIsNullOrNot(this.view)){
            // 查看文章
            RelativeLayout articleLayout = (RelativeLayout) this.view.findViewById(R.id.person_article);
            articleLayout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent = new Intent(getActivity(), ArticleActivity.class);
                    startActivity(intent);
                }
            });

            // 发表文章
            RelativeLayout publishLayout = (RelativeLayout) this.view.findViewById(R.id.person_publich);
            publishLayout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent = new Intent(getActivity(), PublishActivity.class);
                    startActivity(intent);
                }
            });

        }
    }

}
